
def converge(domain, adapt, process, converged):
    def adaption_step(domain, population):
            examples = domain.getBatch()
            return adapt(examples)
    def adaption_steps(threshold = threshold, converged = converged):
        while not converged():
            error = adaption_step()
            yield error


    for error in adaption_steps():
        process(error)






##        for check in xrange(checks):g
##            error = adaption_step()
##            process(error)
##            converged = threshold - error
##            if not converged:
##                break
##


#~ def file_print_process(error, errorfile, retreive, **files):
    #~ '''Performs file-output of performance measures.
#~
     #~ Prints the error to errorfile and retreives further values via methods in
     #~ dict retreive and prints them to files.'''
#~
    #~ print >> errorfile, error
#~
    #~ for k in files.keys():
        #~ print >> files[k], retreive[k]
